package com.example.myapplication

import android.os.Bundle
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        val linearLayout= LinearLayout(this)
        linearLayout.orientation = LinearLayout.VERTICAL
        val textView = TextView(this)
        textView.text = getString(R.string.app_name)
        val imageView = ImageView(this)
        imageView.setImageResource(R.drawable.flag)
        val button = Button(this)
        button.text = getString(R.string.clike_me)
        linearLayout.addView(textView)
        linearLayout.addView(imageView)
        linearLayout.addView(button)
        button.setOnClickListener {
            textView.text = "I was clicked!"
        }

        setContentView(linearLayout)
        ViewCompat.setOnApplyWindowInsetsListener(linearLayout) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        button.setOnClickListener {
            textView.text =getString(R.string.clike_me)
        }
    }
}